import request from './request'

export const clubApi = {
  // 获取俱乐部列表
  getClubList(params) {
    // 转换参数名称：page_size -> pageSize
    const backendParams = {
      page: params.page,
      pageSize: params.page_size || params.pageSize
    }
    
    return request({
      url: '/club/list',
      method: 'get',
      params: backendParams
    })
  },

  // 获取俱乐部详情
  getClubDetail(id) {
    return request({
      url: `/club/${id}`,
      method: 'get'
    })
  },

  // 审核俱乐部（通过）
  approveClub(id) {
    return request({
      url: `/club/${id}/approve`,
      method: 'post'
    })
  },

  // 拒绝俱乐部
  rejectClub(id, reason) {
    return request({
      url: `/club/${id}/reject`,
      method: 'post',
      data: { reason }
    })
  },

  // 获取俱乐部详情
  getClubDetail(id) {
    return request({
      url: `/club/${id}`,
      method: 'get'
    })
  },

  // 获取俱乐部成员
  getClubMembers(id, params) {
    return request({
      url: `/club/${id}/members`,
      method: 'get',
      params
    })
  },

  // 审核成员加入申请
  approveMember(memberId, approved) {
    return request({
      url: `/club/member/${memberId}/approve`,
      method: 'post',
      params: { approved }
    })
  },

  // 踢出成员
  kickMember(clubId, memberId) {
    return request({
      url: `/club/${clubId}/member/${memberId}/kick`,
      method: 'post'
    })
  },

  // 设置成员角色
  setMemberRole(memberId, role) {
    return request({
      url: `/club/member/${memberId}/role`,
      method: 'post',
      params: { role }
    })
  }
}

